<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Conceptual Requirements for Real Number Types</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 3.3.0">
<link rel="up" href="../using_udt.html" title="Chapter 20. Use with User-Defined Floating-Point Types - Boost.Multiprecision and others">
<link rel="prev" href="high_precision/using_test.html" title="Using without expression templates for Boost.Test and others">
<link rel="next" href="dist_concept.html" title="Conceptual Requirements for Distribution Types">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="high_precision/using_test.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../using_udt.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dist_concept.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.real_concepts"></a><a class="link" href="real_concepts.html" title="Conceptual Requirements for Real Number Types">Conceptual Requirements for
    Real Number Types</a>
</h2></div></div></div>
<p>
      The functions and statistical distributions in this library can be used with
      any type <span class="emphasis"><em>RealType</em></span> that meets the conceptual requirements
      given below. All the built-in floating-point types like <code class="computeroutput"><span class="keyword">double</span></code>
      will meet these requirements. (Built-in types are also called <a href="http://en.cppreference.com/w/cpp/language/types" target="_top">fundamental
      (built-in) types</a>).
    </p>
<p>
      User-defined types that meet the conceptual requirements can also be used.
      For example, with <a class="link" href="high_precision/use_ntl.html" title="Using NTL Library">a thin
      wrapper class</a> one of the types provided with <a href="http://shoup.net/ntl/" target="_top">NTL
      (RR)</a> can be used. But now that <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>
      library is available, this has become the preferred real-number type, typically
      <a href="../../../../../libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_dec_float.html" target="_top">cpp_dec_float</a>
      or <a href="../../../../../libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_bin_float.html" target="_top">cpp_bin_float</a>.
    </p>
<p>
      Submissions of binding to other extended precision types would also still be
      welcome.
    </p>
<p>
      The guiding principal behind these requirements is that a <span class="emphasis"><em>RealType</em></span>
      behaves just like a built-in floating-point type.
    </p>
<h5>
<a name="math_toolkit.real_concepts.h0"></a>
      <span class="phrase"><a name="math_toolkit.real_concepts.basic_arithmetic_requirements"></a></span><a class="link" href="real_concepts.html#math_toolkit.real_concepts.basic_arithmetic_requirements">Basic Arithmetic
      Requirements</a>
    </h5>
<p>
      These requirements are common to all of the functions in this library.
    </p>
<p>
      In the following table <span class="emphasis"><em>r</em></span> is an object of type <code class="computeroutput"><span class="identifier">RealType</span></code>, <span class="emphasis"><em>cr</em></span> and <span class="emphasis"><em>cr2</em></span>
      are objects of type <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">RealType</span></code>,
      and <span class="emphasis"><em>ca</em></span> is an object of type <code class="computeroutput"><span class="keyword">const</span>
      <span class="identifier">arithmetic</span><span class="special">-</span><span class="identifier">type</span></code> (arithmetic types include all the built
      in integers and floating point types).
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Expression
              </p>
            </th>
<th>
              <p>
                Result Type
              </p>
            </th>
<th>
              <p>
                Notes
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">RealType</span><span class="special">(</span><span class="identifier">cr</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                RealType is copy constructible.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">RealType</span><span class="special">(</span><span class="identifier">ca</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                RealType is copy constructible from the arithmetic types.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Assignment operator.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Assignment operator from the arithmetic types.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">+=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Adds cr to r.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">+=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Adds ar to r.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">-=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Subtracts cr from r.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">-=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Subtracts ca from r.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">*=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Multiplies r by cr.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">*=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Multiplies r by ca.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">/=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Divides r by cr.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">r</span> <span class="special">/=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Divides r by ca.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="special">-</span><span class="identifier">r</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Unary Negation.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="special">+</span><span class="identifier">r</span></code>
              </p>
            </td>
<td>
              <p>
                RealType&amp;
              </p>
            </td>
<td>
              <p>
                Identity Operation.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">+</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Addition
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">+</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Addition
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">+</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Addition
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">-</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Subtraction
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">-</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Subtraction
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">-</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Subtraction
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">*</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Multiplication
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">*</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Multiplication
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">*</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Multiplication
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">/</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Subtraction
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">/</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Subtraction
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">/</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                Binary Subtraction
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">==</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Equality Comparison
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">==</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Equality Comparison
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">==</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Equality Comparison
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">!=</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Inequality Comparison
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">!=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Inequality Comparison
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">!=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Inequality Comparison
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;=</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Less than equal to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Less than equal to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&lt;=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Less than equal to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;=</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Greater than equal to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;=</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Greater than equal to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&gt;=</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Greater than equal to.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Less than comparison.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Less than comparison.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&lt;</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Less than comparison.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;</span>
                <span class="identifier">cr2</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Greater than comparison.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;</span>
                <span class="identifier">ca</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Greater than comparison.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&gt;</span>
                <span class="identifier">cr</span></code>
              </p>
            </td>
<td>
              <p>
                bool
              </p>
            </td>
<td>
              <p>
                Greater than comparison.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">digits</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
              </p>
            </td>
<td>
              <p>
                int
              </p>
            </td>
<td>
              <p>
                The number of digits in the significand of RealType.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">max_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                The largest representable number by type RealType.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">min_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                The smallest representable number by type RealType.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">log_max_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                The natural logarithm of the largest representable number by type
                RealType.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">log_min_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                The natural logarithm of the smallest representable number by type
                RealType.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">epsilon</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
<td>
              <p>
                The machine epsilon of RealType.
              </p>
            </td>
</tr>
</tbody>
</table></div>
<p>
      Note that:
    </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
          The functions <code class="computeroutput"><span class="identifier">log_max_value</span></code>
          and <code class="computeroutput"><span class="identifier">log_min_value</span></code> can be
          synthesised from the others, and so no explicit specialisation is required.
        </li>
<li class="listitem">
          The function <code class="computeroutput"><span class="identifier">epsilon</span></code> can
          be synthesised from the others, so no explicit specialisation is required
          provided the precision of RealType does not vary at runtime (see the header
          <a href="../../../../../boost/math/bindings/rr.hpp" target="_top">boost/math/bindings/rr.hpp</a>
          for an example where the precision does vary at runtime).
        </li>
<li class="listitem">
          The functions <code class="computeroutput"><span class="identifier">digits</span></code>,
          <code class="computeroutput"><span class="identifier">max_value</span></code> and <code class="computeroutput"><span class="identifier">min_value</span></code>, all get synthesised automatically
          from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span></code>. However, if <code class="computeroutput"><span class="identifier">numeric_limits</span></code> is not specialised for
          type RealType, then you will get a compiler error when code tries to use
          these functions, <span class="emphasis"><em>unless</em></span> you explicitly specialise
          them. For example if the precision of RealType varies at runtime, then
          <code class="computeroutput"><span class="identifier">numeric_limits</span></code> support
          may not be appropriate, see <a href="../../../../../boost/math/bindings/rr.hpp" target="_top">boost/math/bindings/rr.hpp</a>
          for examples.
        </li>
</ol></div>
<div class="warning"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top">
<p>
        If <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;&gt;</span></code>
        is <span class="bold"><strong>not specialized</strong></span> for type <span class="emphasis"><em>RealType</em></span>
        then the default float precision of 6 decimal digits will be used by other
        Boost programs including:
      </p>
<p>
        Boost.Test: giving misleading error messages like
      </p>
<p>
        <span class="emphasis"><em>"difference between {9.79796} and {9.79796} exceeds 5.42101e-19%".</em></span>
      </p>
<p>
        Boost.LexicalCast and Boost.Serialization when converting the number to a
        string, causing potentially serious loss of accuracy on output.
      </p>
<p>
        Although it might seem obvious that RealType should require <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span></code>
        to be specialized, this is not sensible for <code class="computeroutput"><span class="identifier">NTL</span><span class="special">::</span><span class="identifier">RR</span></code> and
        similar classes where the <span class="bold"><strong>number of digits is a runtime
        parameter</strong></span> (whereas for <code class="computeroutput"><span class="identifier">numeric_limits</span></code>
        everything has to be fixed at compile time).
      </p>
</td></tr>
</table></div>
<h5>
<a name="math_toolkit.real_concepts.h1"></a>
      <span class="phrase"><a name="math_toolkit.real_concepts.standard_library_support_require"></a></span><a class="link" href="real_concepts.html#math_toolkit.real_concepts.standard_library_support_require">Standard
      Library Support Requirements</a>
    </h5>
<p>
      Many (though not all) of the functions in this library make calls to standard
      library functions, the following table summarises the requirements. Note that
      most of the functions in this library will only call a small subset of the
      functions listed here, so if in doubt whether a user-defined type has enough
      standard library support to be useable the best advise is to try it and see!
    </p>
<p>
      In the following table <span class="emphasis"><em>r</em></span> is an object of type <code class="computeroutput"><span class="identifier">RealType</span></code>, <span class="emphasis"><em>cr1</em></span> and <span class="emphasis"><em>cr2</em></span>
      are objects of type <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">RealType</span></code>,
      and <span class="emphasis"><em>i</em></span> is an object of type <code class="computeroutput"><span class="keyword">int</span></code>.
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Expression
              </p>
            </th>
<th>
              <p>
                Result Type
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">fabs</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ceil</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">floor</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">exp</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">pow</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">,</span>
                <span class="identifier">cr2</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">log</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">frexp</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">,</span>
                <span class="special">&amp;</span><span class="identifier">i</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ldexp</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">,</span>
                <span class="identifier">i</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">cos</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">sin</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">asin</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">tan</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">atan</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">fmod</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">round</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">iround</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                int
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">trunc</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                RealType
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">itrunc</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
              </p>
            </td>
<td>
              <p>
                int
              </p>
            </td>
</tr>
</tbody>
</table></div>
<p>
      Note that the table above lists only those standard library functions known
      to be used (or likely to be used in the near future) by this library. The following
      functions: <code class="computeroutput"><span class="identifier">acos</span></code>, <code class="computeroutput"><span class="identifier">atan2</span></code>, <code class="computeroutput"><span class="identifier">fmod</span></code>,
      <code class="computeroutput"><span class="identifier">cosh</span></code>, <code class="computeroutput"><span class="identifier">sinh</span></code>,
      <code class="computeroutput"><span class="identifier">tanh</span></code>, <code class="computeroutput"><span class="identifier">log10</span></code>,
      <code class="computeroutput"><span class="identifier">lround</span></code>, <code class="computeroutput"><span class="identifier">llround</span></code>,
      <code class="computeroutput"><span class="identifier">ltrunc</span></code>, <code class="computeroutput"><span class="identifier">lltrunc</span></code>
      and <code class="computeroutput"><span class="identifier">modf</span></code> are not currently
      used, but may be if further special functions are added.
    </p>
<p>
      Note that the <code class="computeroutput"><span class="identifier">round</span></code>, <code class="computeroutput"><span class="identifier">trunc</span></code> and <code class="computeroutput"><span class="identifier">modf</span></code>
      functions are not part of the current C++ standard: they are part of the additions
      added to C99 which will likely be in the next C++ standard. There are Boost
      versions of these provided as a backup, and the functions are always called
      unqualified so that argument-dependent-lookup can take place.
    </p>
<p>
      In addition, for efficient and accurate results, a <a class="link" href="lanczos.html" title="The Lanczos Approximation">Lanczos
      approximation</a> is highly desirable. You may be able to adapt an existing
      approximation from <a href="../../../../../boost/math/special_functions/lanczos.hpp" target="_top">boost/math/special_functions/lanczos.hpp</a>
      or <a href="../../../../../boost/math/bindings/detail/big_lanczos.hpp" target="_top">boost/math/bindings/detail/big_lanczos.hpp</a>:
      in the former case you will need change <code class="computeroutput"><span class="keyword">static_cast</span></code>'s
      to <code class="computeroutput"><span class="identifier">lexical_cast</span></code>'s, and the
      constants to <span class="emphasis"><em>strings</em></span> (in order to ensure the coefficients
      aren't truncated to <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>)
      and then specialise <code class="computeroutput"><span class="identifier">lanczos_traits</span></code>
      for type T. Otherwise you may have to hack <a href="../../../tools/lanczos_generator.cpp" target="_top">libs/math/tools/lanczos_generator.cpp</a>
      to find a suitable approximation for your RealType. The code will still compile
      if you don't do this, but both accuracy and efficiency will be somewhat compromised
      in any function that makes use of the gamma/beta/erf family of functions.
    </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="high_precision/using_test.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../using_udt.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dist_concept.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
